import 'package:flutter/material.dart';
import 'package:xinxuan/common/button_util.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class ActivityFunItem extends StatelessWidget {

  final String path;
  final String title;
  final String subTitle;
  final Function onTap;
  final String btnStr;
  final bool isClick;

  ActivityFunItem({ 
    required this.path, 
    required this.title, 
    required this.subTitle, 
    required this.onTap,
    /// 按钮文字
    required this.btnStr,
    /// 是否可点击
    required this.isClick
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 16.h),
      child: Row(
        children: [
          Image.asset(
            path,
            width: 42.w,
            height: 42.w
          ),
          SizedBox(width: 6.w),
          Expanded(child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                title,
                overflow: TextOverflow.ellipsis,
                maxLines: 1,
                style: TextStyle(
                  color: textBlackColor,
                  fontSize: 14.sp
                ),
              ),
              SizedBox(height: 2.h),
              Text(
                subTitle,
                overflow: TextOverflow.ellipsis,
                maxLines: 1,
                style: TextStyle(
                  color: textSubtitleColor,
                  fontSize: 12.sp
                ),
              )
            ],
          )),
          Container(
            width: 70.w,
            child: isClick ?  ButtonUtil(
              text: btnStr, 
              fontSize: 12.sp, 
              borderRadius: 30.h, 
              height: 30.h, 
              begin: Alignment.centerLeft,
              end: Alignment.centerRight,
              bgColors: [
                activityBtnBg1,
                activityBtnBg2
              ],
              onTop: () => onTap()
            ) : ButtonUtil(
              text: btnStr, 
              fontSize: 12.sp, 
              borderRadius: 30.h, 
              height: 30.h, 
              textColor: mainTextColor,
              bgColors: [
                bgRecoveryStatus,
                bgRecoveryStatus
              ],
              onTop: () {

              }
            ),
          )
        ],
      ),
    );
  }
}